//
//  TwERPPartItem.m
//  TwERP
//
//  Created by Xiangyang Li on 12-7-2.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "TwERPPartItem.h"
#import "TwERPJsonAgent.h"

@implementation TwERPPartItem

@synthesize partName = _partName;
@synthesize partCode = _partCode;
@synthesize customCode = _customCode;
@synthesize price =_price;
@synthesize quantity =_quantity;
@synthesize cc = _cc;
@synthesize cx =_cx;

- (id)init {
    self = [super init];
    if (self) {
        // Initialize self.
        self.quantity = 1;
        self.partCode = @"";
        self.partName = @"";
        self.customCode = @"";
    }
    return self;
}

+ (NSArray *) partsWithKeyword:(NSString *)keyword
{
    NSArray *partDictList=[TwERPJsonAgent getPartListByKeyword:keyword];
    NSMutableArray *partList = [[NSMutableArray alloc] init];
    
    for (NSDictionary *pDict in partDictList)
    {
        TwERPPartItem * part =[[TwERPPartItem alloc] init];
        [part setValuesForKeysWithDictionary:pDict];
        [partList addObject:part];
    }
    return partList;
}

@end
